package com.ruihao.cetralizelogin.auth.center.client.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 错误页面跳转
 * @author sly
 * @time 2019年9月9日
 */
@Controller
public class ErrorController {
    @RequestMapping(value = "/error/{code}")
    public String error(@PathVariable int code, Model model) {
        String pager = "/error/500";
        switch (code) {
            case 403:
                model.addAttribute("code", 403);
                pager = "/error/403";
                break;
            case 404:
                model.addAttribute("code", 404);
                pager = "/error/404";
                break;
            case 500:
                model.addAttribute("code", 500);
                pager = "/error/500";
                break;
             default:
                 model.addAttribute("code",400);
        }
        return pager + ".html";
    }
}
